package com.ruoyi.Application.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.Application.domain.AlgsLaboratoryApplication;
import com.ruoyi.Application.service.IAlgsLaboratoryApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 实验室申请Controller
 * 
 * @author ruoyi
 * @date 2023-03-16
 */
@RestController
@RequestMapping("/application")
public class AlgsLaboratoryApplicationController extends BaseController
{
    @Autowired
    private IAlgsLaboratoryApplicationService algsLaboratoryApplicationService;

    /**
     * 查询实验室申请列表
//     */
//    @RequiresPermissions("Application:application:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        startPage();
        List<AlgsLaboratoryApplication> list = algsLaboratoryApplicationService.selectAlgsLaboratoryApplicationList(algsLaboratoryApplication);
        return getDataTable(list);
    }

    /**
     * 导出实验室申请列表
     */
//    @RequiresPermissions("Application:application:export")
//    @Log(title = "实验室申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        List<AlgsLaboratoryApplication> list = algsLaboratoryApplicationService.selectAlgsLaboratoryApplicationList(algsLaboratoryApplication);
        ExcelUtil<AlgsLaboratoryApplication> util = new ExcelUtil<AlgsLaboratoryApplication>(AlgsLaboratoryApplication.class);
        util.exportExcel(response, list, "实验室申请数据");
    }

    /**
     * 获取实验室申请详细信息
     */
//    @RequiresPermissions("Application:application:query")
    @GetMapping(value = "/{laboratoryApplicationId}")
    public AjaxResult getInfo(@PathVariable("laboratoryApplicationId") Long laboratoryApplicationId)
    {
        return success(algsLaboratoryApplicationService.selectAlgsLaboratoryApplicationByLaboratoryApplicationId(laboratoryApplicationId));
    }

    /**
     * 新增实验室申请
     */
//    @RequiresPermissions("Application:application:add")
//    @Log(title = "实验室申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        algsLaboratoryApplication.setTypeId(24l);
        return toAjax(algsLaboratoryApplicationService.insertAlgsLaboratoryApplication(algsLaboratoryApplication));
    }

    /**
     * 修改实验室申请
     */
//    @RequiresPermissions("Application:application:edit")
    @Log(title = "实验室申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        return toAjax(algsLaboratoryApplicationService.updateAlgsLaboratoryApplication(algsLaboratoryApplication));
    }

    /**
     * 删除实验室申请
     */
//    @RequiresPermissions("Application:application:remove")
//    @Log(title = "实验室申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{laboratoryApplicationIds}")
    public AjaxResult remove(@PathVariable Long[] laboratoryApplicationIds)
    {
        return toAjax(algsLaboratoryApplicationService.deleteAlgsLaboratoryApplicationByLaboratoryApplicationIds(laboratoryApplicationIds));
    }
}
